﻿using System.Activities;
using Microsoft.Build.Framework;
using System.Collections;
using Microsoft.TeamFoundation.Build.Client;

namespace TfsCloudDeploy.Workflow.Core
{
    /// <summary>
    /// Summary description for BuildEngine
    /// </summary>
    internal class BuildEngine : IBuildEngine
    {
        #region Private Fields

        private readonly CodeActivityContext _context;

        #endregion
        
        #region Constructor

        public BuildEngine(CodeActivityContext context)
        {
            _context = context;
        }

        #endregion

        #region IBuildEngine Members

        public bool BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs)
        {
            return true;
        }

        public int ColumnNumberOfTaskNode
        {
            get { return 0; }
        }

        public bool ContinueOnError
        {
            get { return true; }
        }

        public int LineNumberOfTaskNode
        {
            get { return 0; }
        }

        public void LogCustomEvent(CustomBuildEventArgs e)
        {
        }

        public void LogErrorEvent(BuildErrorEventArgs e)
        {
            WorkflowUtility.CreateBuildMessage(string.Format("BuildEngine: [ERROR]: {0}", e.Message), _context, BuildMessageImportance.High);
        }

        public void LogMessageEvent(BuildMessageEventArgs e)
        {
            WorkflowUtility.CreateBuildMessage(string.Format("BuildEngine: [INFO]: {0}", e.Message), _context, BuildMessageImportance.Low);
        }

        public void LogWarningEvent(BuildWarningEventArgs e)
        {
            WorkflowUtility.CreateBuildMessage(string.Format("BuildEngine: [WARNING]: {0}", e.Message), _context, BuildMessageImportance.Normal);
        }

        public string ProjectFileOfTaskNode
        {
            get { return string.Empty; }
        }

        #endregion
    }
}